package cn.buyclss.backend.controller.shop;

import cn.buyclss.backend.entity.support.RespResult;
import cn.buyclss.backend.entity.vo.shop.GoodsSpecsVO;
import cn.buyclss.backend.entity.vo.shop.GoodsVO;
import cn.buyclss.backend.service.shop.GoodsSpecsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Cecurio
 * @create: 2019-03-18 16:52
 **/

@RestController
@RequestMapping("/goods/specs")
@Api(value = "商品规格", description = "商品规格")
public class GoodsSpecsController {

    private Logger logger = LoggerFactory.getLogger(GoodsSpecsController.class);

    @Autowired
    private GoodsSpecsService goodsSpecsService;

    @PostMapping("/one")
    @RequiresRoles("shop")
    @ApiOperation(value = "增加一个商品规格", notes = " <p>操作者角色：shop</p> 增加一个商品规格，一个商品必须有一个规格")
    @ApiImplicitParam(paramType = "header", name = "Authorization", required = true)
    public RespResult addOne(@RequestBody GoodsSpecsVO goodsSpecsVO) {
        logger.info(goodsSpecsVO.toString());
        return goodsSpecsService.addOne(goodsSpecsVO);
    }

}
